package com.myshop.controller;


import com.myshop.entity.Cart;
import com.myshop.entity.Product;
import com.myshop.entity.R;
import com.myshop.service.CartService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 购物车实体(Cart)表控制层
 *
 * @author makejava
 * @since 2023-07-21 16:17:58
 */
@RestController
@RequestMapping("cart")
@CrossOrigin
public class CartController{
    /**
     * 服务对象
     */
    @Autowired
    private CartService cartService;

    /**
     * 购物车新增
     * @param cart
     * @return
     */
    @RequestMapping("/insert")
    public R insert(Cart cart){
        cartService.save(cart);
        return R.succ(null);
    }

    /**
     * 查询购物车
     * @return
     */
    @RequestMapping("/query")
    public R query(){
        return R.succ(cartService.list());
    }

}

